#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'

[Company, BranchOffice, Department, Holiday].each { |x| x.delete_all }

User.all.each do |u|
  u.destroy unless u.login == 'admin'
end

# Create some data

c = Company.create! :name => "Neway", :settings => {}

names = %w(Sede Jurídico Desenvolvimento)
cities = %w(Salvador Capela Londres)
cities.each_index { |i| BranchOffice.create! :company_id => c.id, :name => names[i], :city => cities[i] }

%w(Recursos\ Humanos Tecnologia\ da\ Informação Marketing Jurídico Médico).each do |name|
  Department.create! :name => name
end

reasons = %w(Natal Ano-Novo Dia\ do\ Trabalho São\ João Jogo\ do\ Brasil)
dates = %w(2010-12-25 2010-12-31 2010-05-01 2010-06-24 2010-06-15)

dates.each_index { |i| Holiday.create! :reason => reasons[i], :holiday_date => dates[i], :branch_office_id => BranchOffice.default.id }

BranchOffice.all.each do |b|
  b.departments = Department.all
  b.save!
end

u = User.new
u.login = 'caio'
u.name = 'Caio Almeida'
u.email = 'caiosba@gmail.com'
u.salary = 400.00
u.hours = 20
u.genre = 'm'
u.department_id = Department.first.id
u.branch_office_id = BranchOffice.default.id
u.password = 'caioalmeida'
u.password_confirmation = 'caioalmeida'
u.save!
u.activate!

u = User.new
u.login = 'flavio'
u.name = 'Flávio Escobar'
u.email = 'flavioescobar1@gmail.com'
u.salary = 500.00
u.hours = 10
u.genre = 'm'
u.department_id = Department.find(2).id
u.branch_office_id = BranchOffice.default.id
u.password = 'flavioescobar'
u.password_confirmation = 'flavioescobar'
u.save!
u.activate!

u = User.new
u.login = 'anderson'
u.name = 'Anderson Carvalho'
u.email = 'carvalho.atb@gmail.com'
u.salary = 1000.00
u.hours = 2
u.genre = 'm'
u.department_id = Department.find(3).id
u.branch_office_id = BranchOffice.default.id
u.password = 'anderson'
u.password_confirmation = 'anderson'
u.save!
u.activate!
